package com.sls.core.util;

import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
import java.io.InputStreamReader;

/**
 * 
 * @Description：数据流文件转化为字符串
 * @author Wangxuegang
 * @Date：2013-6-3
 * 
 */
public class FileTransferToString {

	/**
	 * 数据流文件转化为字符串
	 * 
	 * @param xmlStr
	 * @return
	 */
	public static String transferToString(String xmlStr) {
		String temp = null;
		StringBuilder sb = new StringBuilder();
		if (xmlStr != null && !xmlStr.equals("")) {
			try {
				ByteArrayInputStream stringInputStream = new ByteArrayInputStream(
						xmlStr.getBytes());
				InputStreamReader read = new InputStreamReader(
						stringInputStream, "UTF-8");
				BufferedReader bufr = new BufferedReader(read);

				while ((temp = bufr.readLine()) != null) {
					sb.append(temp.trim());
				}
				read.close();
			} catch (Exception e) {
				e.printStackTrace();
			}

		}

		String result = sb.toString().trim();
		return result;
	}

}
